package GUI;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class Staff extends JFrame {

	private JPanel contentPane;
	private JTextField t;
	private JTextField txtPhone;
	private JTextField txtRole;
	private JTextField txtSalary;
	private Success suc;

	/**
	 * Create the frame.
	 */
	public Staff(String s) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 245, 280);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		if(s.equals("new"))
		{
			setTitle("Create New Staff");
		}
		else
		{
			setTitle("Manage Staff");
		}
		
		JLabel lblMemberName = new JLabel("Name: ");
		lblMemberName.setBounds(10, 11, 46, 14);
		contentPane.add(lblMemberName);
		
		JTextField txtName = new JTextField();
		txtName.setBounds(82, 8, 139, 20);
		contentPane.add(txtName);
		txtName.setColumns(10);
		
		JLabel lblSurname = new JLabel("Surname:");
		lblSurname.setBounds(10, 36, 80, 14);
		contentPane.add(lblSurname);
		
		JTextField txtSurname = new JTextField();
		txtSurname.setColumns(10);
		txtSurname.setBounds(82, 33, 139, 20);
		contentPane.add(txtSurname);
		
		JLabel lblCpr = new JLabel("CPR:");
		lblCpr.setBounds(10, 64, 80, 14);
		contentPane.add(lblCpr);
		
		JTextField txtCpr = new JTextField();
		txtCpr.setColumns(10);
		txtCpr.setBounds(82, 61, 139, 20);
		contentPane.add(txtCpr);
		
		JLabel lblAddress = new JLabel("Address:");
		lblAddress.setBounds(10, 89, 80, 14);
		contentPane.add(lblAddress);
		
		JTextField txtAddress = new JTextField();
		txtAddress.setColumns(10);
		txtAddress.setBounds(82, 86, 139, 20);
		contentPane.add(txtAddress);
		
		JLabel lblPhone = new JLabel("Phone:");
		lblPhone.setBounds(10, 114, 46, 14);
		contentPane.add(lblPhone);
		
		txtPhone = new JTextField();
		txtPhone.setBounds(82, 111, 139, 20);
		contentPane.add(txtPhone);
		txtPhone.setColumns(10);
		
		JLabel lblSalary = new JLabel("Salary:");
		lblSalary.setBounds(10, 164, 46, 14);
		contentPane.add(lblSalary);
		
		JLabel lblRole = new JLabel("Role:");
		lblRole.setBounds(10, 139, 46, 14);
		contentPane.add(lblRole);
		
		txtRole = new JTextField();
		txtRole.setBounds(82, 136, 139, 20);
		contentPane.add(txtRole);
		txtRole.setColumns(10);
		
		txtSalary = new JTextField();
		txtSalary.setBounds(82, 161, 139, 20);
		contentPane.add(txtSalary);
		txtSalary.setColumns(10);
		
		JButton btnCancel = new JButton("Cancel");
		btnCancel.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				MainMenu.getInstance().setVisible(true);
				dispose();
			}
		});
		btnCancel.setBounds(10, 207, 89, 23);
		contentPane.add(btnCancel);
		
		JButton btnSave = new JButton("Save");
		if(s.equals("new"))
		{
			
			btnSave.addMouseListener(new MouseAdapter() {
				@Override
				public void mouseClicked(MouseEvent arg0) {
					suc=new Success("cr", false);
					suc.setVisible(true);
					dispose();
				}
			});
			btnSave.setBounds(132, 207, 89, 23);
			contentPane.add(btnSave);
		}
		else{
		btnSave.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				suc =new Success("mng", false);
				suc.setVisible(true);
				dispose();
			}
		});
		btnSave.setBounds(132, 207, 89, 23);
		contentPane.add(btnSave);
		}
		
	}
}
